package com.dg.cuckoo.admin.action.basicInformation.permissionSettings;

import com.dg.cuckoo.admin.dto.basicInformation.permissionSettings.UnitTypeDto;
import com.dg.cuckoo.admin.service.UnitTypeService;
import com.dg.cuckoo.common.utils.PageModel;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 基本资料-权限设置-单位类型
 */
@RestController
@RequestMapping("/basicInformation/permissionSettings/unitType")
public class UnitType extends BaseController {

    @Autowired
    private UnitTypeService service;

    /**
     * 新增
     */
    @PostMapping("save")
    public JsonResult<Void> save(UnitTypeDto dto){
        service.save(dto);
        return new JsonResult<>(OK);
    }

    /**
     * 删除
     */
    @PostMapping("delect/{id}")
    public JsonResult<Void> delect(@PathVariable  String id){
        service.delect(id);
        return new JsonResult<>(OK);
    }

    /**
     * 禁用
     */
    @PostMapping("disable/{id}")
    public JsonResult<Void> disable(@PathVariable String id){
        service.disable(id);
        return new JsonResult<>(OK);
    }

    /**
     * 启用
     */
    @PostMapping("start/{id}")
    public JsonResult<Void> start(@PathVariable  String id){
        service.start(id);
        return new JsonResult<>(OK);
    }

    /**
     * 点击显示数据
     */
    @PostMapping("openSelect/{id}")
    public JsonResult<UnitTypeDto> openSelect(@PathVariable String id){
        UnitTypeDto data = service.openSelect(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 分页
     * @param page 页
     * @param pageSize 页数
     * @return
     */
    @PostMapping("page/{page}/{pageSize}")
    public JsonResult<PageModel> page(@PathVariable Integer page, @PathVariable Integer pageSize){
        PageModel data = service.page(page, pageSize);
        return new JsonResult<>(OK,data);
    }

    /**
     * 修改
     */
    @PostMapping("update/{id}")
    public JsonResult<Void> update(@PathVariable String id,UnitTypeDto dto){
        service.update(id,dto);
        return new JsonResult<>(OK);
    }



}
